import numpy as np
import scipy.stats as stats
import matplotlib.pyplot as plt
import math
import pandas as pd
from jqdata import *


def getSecPeriodRet(stocklist: list, duration: int, check_date)-> list:
    df_price=get_price(stocklist, count=duration, end_date=check_date, skip_paused=True, panel=False)
    sr_rps =df_price.groupby("code").apply(lambda x:x.iloc[-1].close/x.iloc[0].close) # 返回的df行数为每个股票一行
    sr_rps =sr_rps.sort_values(ascending=False)#.head(int(df_price.shape[0]*ratio))
    sr_rps =sr_rps.dropna()
    poollist = sr_rps.index.tolist()
    return poollist
